<?php

//UMA new
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCustomerHistoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customer_histories', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('temporary_member_id', 128)->nullable()->comment('会員仮ID');
            $table->text('input_info')->comment('入力情報');
            $table->string('working_years', 2)->nullable()->comment('勤続年数');
            $table->boolean('usage_term_accepted')->comment('利用規約 1:同意; 0:同意しない');
            $table->smallInteger('score')->nullable()->comment('スコア');
            $table->double('min_interests', 4, 2)->nullable()->comment('住宅ローン商品（⾦利）最小値');
            $table->double('max_interests', 4, 2)->nullable()->comment('住宅ローン商品（⾦利）最大値');
            $table->double('min_total_payment', 10, 1)->nullable()->comment('住宅購⼊可能額最小値');
            $table->double('max_total_payment', 10, 1)->nullable()->comment('住宅購⼊可能額最大値');
            $table->smallInteger('nikkei_score')->nullable()->comment('日経のスコア');
            $table->smallInteger('random_score')->nullable()->comment('ランダムスコア');
            $table->string('ip', 16)->nullable()->comment('ip address');
            $table->string('user_agent', 128)->nullable()->comment('ブラウザー');
            $table->string('operation_system', 128)->nullable()->comment('OS');
            $table->unsignedBigInteger('company_id')->nullable()->comment('会社ID');
            $table->integer('score_rank_id')->nullable()->comment('rank id');
            $table->integer('customer_id')->nullable()->comment('customer id');

            $table->timestamps();
            //$table->foreign('company_id')->references('id')->on('companies');
            $table->index('score');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('customer_histories');
    }
}
